def solution(n: int, u: list) -> int:
    # PLEASE DO NOT MODIFY THE FUNCTION SIGNATURE
    # write code here
    res = [0] * n
    for i in range(n - 1):
        for j in range(i + 1, len(u)):
            if u[i] == u[j]:
                continue
            if u[i] > u[j]:
                res[i] = 1
            else:
                res[j] = 1

    return res.count(1)


def solution1(n: int, u: list) -> int:
    # PLEASE DO NOT MODIFY THE FUNCTION SIGNATURE
    # write code here
    assert n == len(u)
    return n - u.count(min(u))


if __name__ == '__main__':
    print(solution(n=5, u=[1, 2, 3, 1, 2]) == 3)
    print(solution(n=4, u=[100000, 100000, 100000, 100000]) == 0)
    print(solution(n=6, u=[1, 1, 1, 2, 2, 2]) == 3)
